﻿using System;
using System.Collections.Generic;
using KPI.Data;
using KPI.Entity;
using TYBase;

namespace KPI.Api
{
    public class UserTestApi
    {
        public static RPage<ExamUserVO> GetPageList(PageInfo page, UserTestQueryDto queryDto)
        {
            try
            {

                LocalHttp http = new LocalHttp();
                if (!http.SetBaseUri(KPIData.ServerURL)
                    .SetUrl($"/examUser/getPageList?{page.AsQueryData()}&{queryDto.AsQueryData()}")
                    .SetGet().Excute(out string data))
                {
                    return RPage<ExamUserVO>.Fail(data);
                }
                return data.AsModel<RPage<ExamUserVO>>();
            }
            catch (Exception ex)
            {
                return RPage<ExamUserVO>.Fail("获取数据失败!", ex);
            }
        }
        public static R<List<ExamUserVO>> GetList(UserTestQueryDto queryDto)
        {
            try
            {

                LocalHttp http = new LocalHttp();
                if (!http.SetBaseUri(KPIData.ServerURL)
                    .SetUrl($"/examUser/getList?{queryDto.AsQueryData()}")
                    .SetGet().Excute(out string data))
                {
                    return R<List<ExamUserVO>>.Fail(data);
                }
                return data.AsModel<R<List<ExamUserVO>>>();
            }
            catch (Exception ex)
            {
                return R<List<ExamUserVO>>.Fail("获取数据失败!", ex);
            }
        }
        public static R<ExamUserVO> GetItemById(string uuid)
        {
            try
            {
                LocalHttp http = new LocalHttp();
                if (!http.SetBaseUri(KPIData.ServerURL)
                    .SetUrl($"/examUser/getItemById?uuid={uuid}")
                    .SetGet().Excute(out string data))
                {
                    return R<ExamUserVO>.Fail(data);
                }
                return data.AsModel<R<ExamUserVO>>();
            }
            catch (Exception ex)
            {
                return R<ExamUserVO>.Fail("获取数据异常!", ex);
            }
        }

        public static R<object> Correct(Tbl_ExamUser queryDto)
        {

            try
            {
                LocalHttp http = new LocalHttp();
                if (!http.SetBaseUri(KPIData.ServerURL)
                    .SetUrl($"/examUser/correct")
                    .SetData(queryDto.JsonAsString())
                    .SetPost().Excute(out string data))
                {
                    return R<object>.Fail(data);
                }
                return data.AsModel<R<object>>();
            }
            catch (Exception ex)
            {
                return R<object>.Fail("提交异常!", ex);
            }
        }
    }
}
